/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * IssueNote.java
 *
 * 
 */
package UI;

import Model.Book;
import Model.IssueNote;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.Socket;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import javax.swing.JTable;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author Administrator
 */
public class frmIssueNote extends javax.swing.JDialog {

 
    ObjectOutputStream out;
    ObjectInputStream in;
    DefaultTableModel modelBorrow, modelReturn, modelReport;
    ArrayList<Book> arrBook;
    ArrayList<IssueNote> arrIss;
    int rowSelectedBorrow = -1, rowSelectedReturn = -1;

    public frmIssueNote(java.awt.Frame parent, boolean modal, ObjectOutputStream out,ObjectInputStream in) {
        super(parent, modal);
        try {
            UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
            //  UIManager.put("Button.showMnemonics",Boolean.TRUE);
        } catch (InstantiationException ex) {
            ex.printStackTrace();
        } catch (UnsupportedLookAndFeelException ex) {
            ex.printStackTrace();
        } catch (IllegalAccessException ex) {
            ex.printStackTrace();
        } catch (ClassNotFoundException ex) {
            ex.printStackTrace();
        }
        initComponents();
        try {
            this.in = in;this.out =out;
            modelBorrow = (DefaultTableModel) tbBorrow.getModel();
            modelReturn = (DefaultTableModel) tbReturnBook.getModel();
            modelReport = (DefaultTableModel) tbReport.getModel();
            arrBook = new ArrayList<>();
            arrIss = new ArrayList<>();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void cancel() {
        int option = JOptionPane.showConfirmDialog(this, "Are you sure want to exit ?", "Exit", JOptionPane.OK_CANCEL_OPTION);
        if (option == JOptionPane.OK_OPTION) {
        
                // TODO add your handling code here:
//                out.close();
//                in.close();
//                cs.close();
         
            this.setVisible(false);
            this.dispose();
        }
    }

    private void removeTable(JTable tb, DefaultTableModel model) {
        while (tb.getRowCount() > 0) {
            model.removeRow(tb.getRowCount() - 1);
        }
    }

    private void showDataBorrow() {
        removeTable(tbBorrow, modelBorrow);
        for (Book b : arrBook) {
            modelBorrow.addRow(b.toVector());
        }
    }

    private void formBorrow(Book book) {
        txtBookIDBorrow.setText(book.BookID);
        txtTitleBorrow.setText(book.Title);
        txtAuthorBorrow.setText(book.Author);
        txtPublisherBorrow.setText(book.Publisher);
        txtSumary.setText(book.Sumary);
        Calendar cal = Calendar.getInstance();
        SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/YYYY");
        String NowDate = sdf.format(cal.getTime());//Lay ngay hien tai  
        cal.add(Calendar.DAY_OF_MONTH, 7);//Tang ngay hien tai len 7 ngay
        String Due = sdf.format(cal.getTime());//Lay ngay da tang
        txtIssueDateBorrow.setText(NowDate);
        txtDueDateBorrow.setText(Due);
    }

    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        pnMain = new javax.swing.JPanel();
        lblPicture = new javax.swing.JLabel();
        tabPaneIssue = new javax.swing.JTabbedPane();
        pnBorrowbook = new javax.swing.JPanel();
        lblBookIDBorrow = new javax.swing.JLabel();
        lblTitleBorrow = new javax.swing.JLabel();
        lblIssueDateBorrow = new javax.swing.JLabel();
        lblDueDateBorrow = new javax.swing.JLabel();
        txtSearchBookBorrow = new javax.swing.JTextField();
        pnButton = new javax.swing.JPanel();
        btnBorrow = new javax.swing.JButton();
        btnreset = new javax.swing.JButton();
        btnExit = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        tbBorrow = new javax.swing.JTable();
        lblReaderID = new javax.swing.JLabel();
        txtBookIDBorrow = new javax.swing.JTextField();
        txtAuthorBorrow = new javax.swing.JTextField();
        txtIssueDateBorrow = new javax.swing.JTextField();
        txtDueDateBorrow = new javax.swing.JTextField();
        txtReaderIDBorrow = new javax.swing.JTextField();
        lblAuthorBorrow = new javax.swing.JLabel();
        lblCategoryBorrow = new javax.swing.JLabel();
        lblSumaryBorrow = new javax.swing.JLabel();
        txtPublisherBorrow = new javax.swing.JTextField();
        txtTitleBorrow = new javax.swing.JTextField();
        jScrollPane4 = new javax.swing.JScrollPane();
        txtSumary = new javax.swing.JTextArea();
        cbSearchBorrow = new javax.swing.JComboBox();
        btnSearchBorrow = new javax.swing.JButton();
        pnReturnBook = new javax.swing.JPanel();
        lblBookIDReturn = new javax.swing.JLabel();
        lblIssueDateReturn = new javax.swing.JLabel();
        lblDuaDateReturn = new javax.swing.JLabel();
        lblReturnDate = new javax.swing.JLabel();
        lblLateFeeReturn = new javax.swing.JLabel();
        btnReturn = new javax.swing.JButton();
        txtReaderIDReturn = new javax.swing.JTextField();
        txtBookIDReturn = new javax.swing.JTextField();
        txtIssueDateReturn = new javax.swing.JTextField();
        txtDueDateReturn = new javax.swing.JTextField();
        txtReturnDate = new javax.swing.JTextField();
        txtLateFees = new javax.swing.JTextField();
        jScrollPane2 = new javax.swing.JScrollPane();
        tbReturnBook = new javax.swing.JTable();
        btnResetReturn = new javax.swing.JButton();
        btnExitReturn = new javax.swing.JButton();
        lblReaderIDReturn = new javax.swing.JLabel();
        txtSearchBookReturn = new javax.swing.JTextField();
        btncheckFee = new javax.swing.JButton();
        VND = new javax.swing.JLabel();
        txtIssueCodeReturn = new javax.swing.JTextField();
        lblIssueCodeReturn = new javax.swing.JLabel();
        cbSearchReturn = new javax.swing.JComboBox();
        btnSearchReturn = new javax.swing.JButton();
        pnReportIssueNote = new javax.swing.JPanel();
        jScrollPane3 = new javax.swing.JScrollPane();
        tbReport = new javax.swing.JTable();
        cbSearchReport = new javax.swing.JComboBox();
        txtSearchReport = new javax.swing.JTextField();
        btnSearchReport = new javax.swing.JButton();
        lblBanner = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Issue Note Management System");
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                formWindowClosing(evt);
            }
        });

        pnMain.setBackground(new java.awt.Color(0, 215, 255));
        pnMain.setPreferredSize(new java.awt.Dimension(800, 600));

        lblPicture.setBackground(new java.awt.Color(255, 0, 0));
        lblPicture.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/IssueNote.png"))); // NOI18N

        tabPaneIssue.setTabPlacement(javax.swing.JTabbedPane.LEFT);

        pnBorrowbook.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Borrow Book", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 12))); // NOI18N

        lblBookIDBorrow.setText("BookID");

        lblTitleBorrow.setText("Title");

        lblIssueDateBorrow.setText("IssueDate");

        lblDueDateBorrow.setText("DueDate");

        txtSearchBookBorrow.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                txtSearchBookBorrowMouseClicked(evt);
            }
        });
        txtSearchBookBorrow.addCaretListener(new javax.swing.event.CaretListener() {
            public void caretUpdate(javax.swing.event.CaretEvent evt) {
                txtSearchBookBorrowCaretUpdate(evt);
            }
        });

        btnBorrow.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/Next.png"))); // NOI18N
        btnBorrow.setText("Borrow ");
        btnBorrow.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnBorrowActionPerformed(evt);
            }
        });
        pnButton.add(btnBorrow);

        btnreset.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/reset.png"))); // NOI18N
        btnreset.setText("Reset");
        btnreset.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnresetActionPerformed(evt);
            }
        });
        pnButton.add(btnreset);

        btnExit.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/Exit.png"))); // NOI18N
        btnExit.setText("Exit");
        btnExit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnExitActionPerformed(evt);
            }
        });
        pnButton.add(btnExit);

        tbBorrow.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "BookID", "Title", "Author", "Publisher"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        tbBorrow.getTableHeader().setReorderingAllowed(false);
        tbBorrow.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tbBorrowMouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(tbBorrow);
        tbBorrow.getColumnModel().getColumn(0).setResizable(false);
        tbBorrow.getColumnModel().getColumn(1).setResizable(false);
        tbBorrow.getColumnModel().getColumn(2).setResizable(false);
        tbBorrow.getColumnModel().getColumn(3).setResizable(false);

        lblReaderID.setText("ReaderID");

        txtBookIDBorrow.setEditable(false);

        txtAuthorBorrow.setEditable(false);

        txtIssueDateBorrow.setEditable(false);

        txtDueDateBorrow.setEditable(false);

        txtReaderIDBorrow.addCaretListener(new javax.swing.event.CaretListener() {
            public void caretUpdate(javax.swing.event.CaretEvent evt) {
                txtReaderIDBorrowCaretUpdate(evt);
            }
        });

        lblAuthorBorrow.setText("Author");

        lblCategoryBorrow.setText("Publiser");

        lblSumaryBorrow.setText("Sumary");

        txtPublisherBorrow.setEditable(false);

        txtTitleBorrow.setEditable(false);

        txtSumary.setEditable(false);
        txtSumary.setColumns(20);
        txtSumary.setRows(5);
        jScrollPane4.setViewportView(txtSumary);

        cbSearchBorrow.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "---Choose---", "BookID", "Title" }));

        btnSearchBorrow.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/ButtonSearch.png"))); // NOI18N
        btnSearchBorrow.setText("Search");
        btnSearchBorrow.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSearchBorrowActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout pnBorrowbookLayout = new javax.swing.GroupLayout(pnBorrowbook);
        pnBorrowbook.setLayout(pnBorrowbookLayout);
        pnBorrowbookLayout.setHorizontalGroup(
            pnBorrowbookLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnBorrowbookLayout.createSequentialGroup()
                .addGroup(pnBorrowbookLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pnBorrowbookLayout.createSequentialGroup()
                        .addGap(163, 163, 163)
                        .addComponent(pnButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(pnBorrowbookLayout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(pnBorrowbookLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jScrollPane1)
                            .addGroup(pnBorrowbookLayout.createSequentialGroup()
                                .addComponent(cbSearchBorrow, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(16, 16, 16)
                                .addComponent(txtSearchBookBorrow, javax.swing.GroupLayout.PREFERRED_SIZE, 160, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(btnSearchBorrow)
                                .addGap(0, 0, Short.MAX_VALUE)))))
                .addContainerGap())
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnBorrowbookLayout.createSequentialGroup()
                .addGap(14, 14, 14)
                .addGroup(pnBorrowbookLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(lblBookIDBorrow)
                    .addComponent(lblTitleBorrow)
                    .addComponent(lblAuthorBorrow)
                    .addComponent(lblSumaryBorrow)
                    .addComponent(lblReaderID))
                .addGap(70, 70, 70)
                .addGroup(pnBorrowbookLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pnBorrowbookLayout.createSequentialGroup()
                        .addComponent(txtReaderIDBorrow, javax.swing.GroupLayout.PREFERRED_SIZE, 186, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(pnBorrowbookLayout.createSequentialGroup()
                        .addGroup(pnBorrowbookLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(pnBorrowbookLayout.createSequentialGroup()
                                .addGroup(pnBorrowbookLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(txtBookIDBorrow)
                                    .addComponent(txtTitleBorrow, javax.swing.GroupLayout.DEFAULT_SIZE, 186, Short.MAX_VALUE)
                                    .addComponent(txtAuthorBorrow))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 86, Short.MAX_VALUE)
                                .addGroup(pnBorrowbookLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(lblCategoryBorrow, javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(lblIssueDateBorrow, javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(lblDueDateBorrow, javax.swing.GroupLayout.Alignment.TRAILING))
                                .addGap(43, 43, 43)
                                .addGroup(pnBorrowbookLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                    .addComponent(txtIssueDateBorrow, javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(txtPublisherBorrow, javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(txtDueDateBorrow, javax.swing.GroupLayout.PREFERRED_SIZE, 186, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 509, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addContainerGap(53, Short.MAX_VALUE))))
        );
        pnBorrowbookLayout.setVerticalGroup(
            pnBorrowbookLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnBorrowbookLayout.createSequentialGroup()
                .addGap(21, 21, 21)
                .addGroup(pnBorrowbookLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblBookIDBorrow)
                    .addComponent(txtBookIDBorrow, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblCategoryBorrow)
                    .addComponent(txtPublisherBorrow, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(pnBorrowbookLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblTitleBorrow)
                    .addComponent(txtTitleBorrow, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblIssueDateBorrow)
                    .addComponent(txtIssueDateBorrow, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(pnBorrowbookLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblDueDateBorrow)
                    .addComponent(txtDueDateBorrow, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblAuthorBorrow)
                    .addComponent(txtAuthorBorrow, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGroup(pnBorrowbookLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pnBorrowbookLayout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addComponent(lblSumaryBorrow)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnBorrowbookLayout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)))
                .addGroup(pnBorrowbookLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblReaderID)
                    .addComponent(txtReaderIDBorrow, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(pnButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(26, 26, 26)
                .addGroup(pnBorrowbookLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtSearchBookBorrow, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cbSearchBorrow, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnSearchBorrow))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 134, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        tabPaneIssue.addTab("   Borrow Book", new javax.swing.ImageIcon(getClass().getResource("/Images/BroowBook.png")), pnBorrowbook); // NOI18N

        pnReturnBook.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Return Book", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 12))); // NOI18N

        lblBookIDReturn.setText("BookID");

        lblIssueDateReturn.setText("IssueDate:");

        lblDuaDateReturn.setText("DueDate:");

        lblReturnDate.setText("ReturnDate:");

        lblLateFeeReturn.setText("LateFees:");

        btnReturn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/Back.png"))); // NOI18N
        btnReturn.setText("Return");
        btnReturn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnReturnActionPerformed(evt);
            }
        });

        txtReaderIDReturn.setEnabled(false);
        txtReaderIDReturn.addCaretListener(new javax.swing.event.CaretListener() {
            public void caretUpdate(javax.swing.event.CaretEvent evt) {
                txtReaderIDReturnCaretUpdate(evt);
            }
        });
        txtReaderIDReturn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtReaderIDReturnActionPerformed(evt);
            }
        });

        txtBookIDReturn.setEnabled(false);

        txtIssueDateReturn.setEnabled(false);

        txtDueDateReturn.setEnabled(false);

        txtReturnDate.setEnabled(false);

        txtLateFees.setEditable(false);

        tbReturnBook.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "IssueID", "ReaderID", "BookID", "DueDate", "IssueDate"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        tbReturnBook.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tbReturnBookMouseClicked(evt);
            }
        });
        jScrollPane2.setViewportView(tbReturnBook);
        tbReturnBook.getColumnModel().getColumn(0).setResizable(false);
        tbReturnBook.getColumnModel().getColumn(1).setResizable(false);
        tbReturnBook.getColumnModel().getColumn(2).setResizable(false);
        tbReturnBook.getColumnModel().getColumn(3).setResizable(false);
        tbReturnBook.getColumnModel().getColumn(4).setResizable(false);

        btnResetReturn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/reset.png"))); // NOI18N
        btnResetReturn.setText("Reset");
        btnResetReturn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnResetReturnActionPerformed(evt);
            }
        });

        btnExitReturn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/Exit.png"))); // NOI18N
        btnExitReturn.setText("Exit");
        btnExitReturn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnExitReturnActionPerformed(evt);
            }
        });

        lblReaderIDReturn.setText("ReaderID");

        txtSearchBookReturn.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                txtSearchBookReturnMouseClicked(evt);
            }
        });
        txtSearchBookReturn.addCaretListener(new javax.swing.event.CaretListener() {
            public void caretUpdate(javax.swing.event.CaretEvent evt) {
                txtSearchBookReturnCaretUpdate(evt);
            }
        });
        txtSearchBookReturn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtSearchBookReturnActionPerformed(evt);
            }
        });

        btncheckFee.setText("Check Fine");
        btncheckFee.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btncheckFeeActionPerformed(evt);
            }
        });

        VND.setText("VNĐ");

        txtIssueCodeReturn.setEditable(false);

        lblIssueCodeReturn.setText("Issue Code");

        cbSearchReturn.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "---Choose---", "BookID", "Title", "ReaderID", "FullName" }));

        btnSearchReturn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/ButtonSearch.png"))); // NOI18N
        btnSearchReturn.setText("Search");
        btnSearchReturn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSearchReturnActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout pnReturnBookLayout = new javax.swing.GroupLayout(pnReturnBook);
        pnReturnBook.setLayout(pnReturnBookLayout);
        pnReturnBookLayout.setHorizontalGroup(
            pnReturnBookLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnReturnBookLayout.createSequentialGroup()
                .addGroup(pnReturnBookLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pnReturnBookLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 712, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(pnReturnBookLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(cbSearchReturn, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(txtSearchBookReturn, javax.swing.GroupLayout.PREFERRED_SIZE, 168, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(btnSearchReturn))
                    .addGroup(pnReturnBookLayout.createSequentialGroup()
                        .addGap(106, 106, 106)
                        .addGroup(pnReturnBookLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(pnReturnBookLayout.createSequentialGroup()
                                .addGroup(pnReturnBookLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(lblBookIDReturn)
                                    .addComponent(lblIssueDateReturn)
                                    .addComponent(lblDuaDateReturn)
                                    .addComponent(lblReturnDate)
                                    .addComponent(lblLateFeeReturn)
                                    .addComponent(lblReaderIDReturn)
                                    .addComponent(lblIssueCodeReturn))
                                .addGap(76, 76, 76)
                                .addGroup(pnReturnBookLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(txtBookIDReturn)
                                    .addComponent(txtIssueDateReturn)
                                    .addComponent(txtDueDateReturn)
                                    .addComponent(txtReturnDate)
                                    .addComponent(txtReaderIDReturn)
                                    .addGroup(pnReturnBookLayout.createSequentialGroup()
                                        .addComponent(txtLateFees, javax.swing.GroupLayout.PREFERRED_SIZE, 129, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(VND))
                                    .addComponent(txtIssueCodeReturn, javax.swing.GroupLayout.PREFERRED_SIZE, 189, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(34, 34, 34)
                                .addComponent(btncheckFee))
                            .addGroup(pnReturnBookLayout.createSequentialGroup()
                                .addGap(38, 38, 38)
                                .addComponent(btnReturn)
                                .addGap(41, 41, 41)
                                .addComponent(btnResetReturn)
                                .addGap(33, 33, 33)
                                .addComponent(btnExitReturn)))))
                .addContainerGap(11, Short.MAX_VALUE))
        );
        pnReturnBookLayout.setVerticalGroup(
            pnReturnBookLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnReturnBookLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnReturnBookLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtIssueCodeReturn, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblIssueCodeReturn))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnReturnBookLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lblReaderIDReturn)
                    .addComponent(txtReaderIDReturn, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(pnReturnBookLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblBookIDReturn)
                    .addComponent(txtBookIDReturn, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(pnReturnBookLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblIssueDateReturn)
                    .addComponent(txtIssueDateReturn, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(pnReturnBookLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblDuaDateReturn)
                    .addComponent(txtDueDateReturn, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(pnReturnBookLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblReturnDate)
                    .addComponent(txtReturnDate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(pnReturnBookLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblLateFeeReturn)
                    .addComponent(txtLateFees, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btncheckFee)
                    .addComponent(VND))
                .addGap(18, 18, 18)
                .addGroup(pnReturnBookLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnReturn)
                    .addComponent(btnResetReturn)
                    .addComponent(btnExitReturn))
                .addGap(31, 31, 31)
                .addGroup(pnReturnBookLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnSearchReturn)
                    .addComponent(txtSearchBookReturn, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cbSearchReturn, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 119, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        tabPaneIssue.addTab("     Return Book ", new javax.swing.ImageIcon(getClass().getResource("/Images/ReturnBookicon.png")), pnReturnBook); // NOI18N

        pnReportIssueNote.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Report Issue", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 12))); // NOI18N

        tbReport.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "IssueID", "ReaderID", "BookID", "DueDate", "IssueDate", "ReturnDate", "Fine"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        tbReport.getTableHeader().setReorderingAllowed(false);
        jScrollPane3.setViewportView(tbReport);
        tbReport.getColumnModel().getColumn(0).setResizable(false);
        tbReport.getColumnModel().getColumn(1).setResizable(false);
        tbReport.getColumnModel().getColumn(2).setResizable(false);
        tbReport.getColumnModel().getColumn(3).setResizable(false);
        tbReport.getColumnModel().getColumn(4).setResizable(false);
        tbReport.getColumnModel().getColumn(5).setResizable(false);
        tbReport.getColumnModel().getColumn(6).setResizable(false);

        cbSearchReport.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "---Choose---", "BookID", "Title", "ReaderID", "FullName" }));

        txtSearchReport.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                txtSearchReportMouseClicked(evt);
            }
        });

        btnSearchReport.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/ButtonSearch.png"))); // NOI18N
        btnSearchReport.setText("Search");
        btnSearchReport.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSearchReportActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout pnReportIssueNoteLayout = new javax.swing.GroupLayout(pnReportIssueNote);
        pnReportIssueNote.setLayout(pnReportIssueNoteLayout);
        pnReportIssueNoteLayout.setHorizontalGroup(
            pnReportIssueNoteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnReportIssueNoteLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnReportIssueNoteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 712, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(pnReportIssueNoteLayout.createSequentialGroup()
                        .addComponent(cbSearchReport, javax.swing.GroupLayout.PREFERRED_SIZE, 86, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(txtSearchReport, javax.swing.GroupLayout.PREFERRED_SIZE, 147, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnSearchReport)))
                .addContainerGap(11, Short.MAX_VALUE))
        );
        pnReportIssueNoteLayout.setVerticalGroup(
            pnReportIssueNoteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnReportIssueNoteLayout.createSequentialGroup()
                .addGap(21, 21, 21)
                .addGroup(pnReportIssueNoteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cbSearchReport, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtSearchReport, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnSearchReport))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 14, Short.MAX_VALUE)
                .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(1, 1, 1))
        );

        tabPaneIssue.addTab("Report IssueNote", new javax.swing.ImageIcon(getClass().getResource("/Images/Report.png")), pnReportIssueNote); // NOI18N

        lblBanner.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/BannerDVT.gif"))); // NOI18N

        javax.swing.GroupLayout pnMainLayout = new javax.swing.GroupLayout(pnMain);
        pnMain.setLayout(pnMainLayout);
        pnMainLayout.setHorizontalGroup(
            pnMainLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnMainLayout.createSequentialGroup()
                .addGroup(pnMainLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pnMainLayout.createSequentialGroup()
                        .addComponent(lblPicture)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(lblBanner, javax.swing.GroupLayout.PREFERRED_SIZE, 672, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(pnMainLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(tabPaneIssue, javax.swing.GroupLayout.PREFERRED_SIZE, 919, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        pnMainLayout.setVerticalGroup(
            pnMainLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnMainLayout.createSequentialGroup()
                .addGroup(pnMainLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lblPicture, javax.swing.GroupLayout.DEFAULT_SIZE, 147, Short.MAX_VALUE)
                    .addComponent(lblBanner, javax.swing.GroupLayout.PREFERRED_SIZE, 141, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(tabPaneIssue, javax.swing.GroupLayout.PREFERRED_SIZE, 533, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(pnMain, javax.swing.GroupLayout.PREFERRED_SIZE, 919, javax.swing.GroupLayout.PREFERRED_SIZE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(pnMain, javax.swing.GroupLayout.PREFERRED_SIZE, 697, javax.swing.GroupLayout.PREFERRED_SIZE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void txtReaderIDReturnCaretUpdate(javax.swing.event.CaretEvent evt) {//GEN-FIRST:event_txtReaderIDReturnCaretUpdate
        // TODO add your handling code here:
}//GEN-LAST:event_txtReaderIDReturnCaretUpdate
    private void formReturn(IssueNote iss) {
        txtIssueCodeReturn.setText(iss.IssueID + "");
        txtReaderIDReturn.setText(iss.ReaderID);
        txtBookIDReturn.setText(iss.BookID);
        txtIssueDateReturn.setText(iss.IssueDate);
        txtDueDateReturn.setText(iss.DueDate);
        Calendar cal = Calendar.getInstance();
        SimpleDateFormat sdf = new SimpleDateFormat("YYYY-MM-dd");
        String NowDate = sdf.format(cal.getTime());//Lay ngay hien tai  
        txtReturnDate.setText(NowDate);
    }
    private void tbReturnBookMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tbReturnBookMouseClicked
        // TODO add your handling code here:
        rowSelectedReturn = tbReturnBook.getSelectedRow();
        if (rowSelectedReturn < 0) {
            return;
        }
        if (!arrIss.isEmpty()) {
            formReturn(arrIss.get(rowSelectedReturn));
        }

}//GEN-LAST:event_tbReturnBookMouseClicked

    private void btnresetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnresetActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_btnresetActionPerformed

    private void btnExitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnExitActionPerformed
        // TODO add your handling code here:
        cancel();
}//GEN-LAST:event_btnExitActionPerformed

    private void txtSearchBookBorrowCaretUpdate(javax.swing.event.CaretEvent evt) {//GEN-FIRST:event_txtSearchBookBorrowCaretUpdate
        // TODO add your handling code here:
}//GEN-LAST:event_txtSearchBookBorrowCaretUpdate

    private void btnBorrowActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBorrowActionPerformed
        String ReaderID = txtReaderIDBorrow.getText();
        String BookID = txtBookIDBorrow.getText();
        if (rowSelectedBorrow == -1) {
            JOptionPane.showMessageDialog(this, "Please choice book");
            return;
        }
        if (ReaderID.equals("")) {
            JOptionPane.showMessageDialog(this, "Please typing ReaderID");
            txtReaderIDBorrow.requestFocus();
            return;
        }
        try {
            out.writeObject("BorrowBook");
            out.writeObject(ReaderID);
            out.writeObject(BookID);
            String tb = (String) in.readObject();
            JOptionPane.showMessageDialog(this, tb);
            removeTable(tbBorrow, modelBorrow);//Sau khi cho muon, du thanh cong hay khong deu xoa bang
            rowSelectedBorrow = -1;
            //Dam bao k dc kick lien tuc gay loi
        } catch (Exception e) {
            e.printStackTrace();
        }
    }//GEN-LAST:event_btnBorrowActionPerformed

    private void tbBorrowMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tbBorrowMouseClicked
        rowSelectedBorrow = tbBorrow.getSelectedRow();
        if (rowSelectedBorrow < 0) {
            return;
        }
        if (!arrBook.isEmpty()) {
            formBorrow(arrBook.get(rowSelectedBorrow));
        }
    }//GEN-LAST:event_tbBorrowMouseClicked

    private void txtBookIDBorrowCaretUpdate(javax.swing.event.CaretEvent evt) {//GEN-FIRST:event_txtBookIDBorrowCaretUpdate
        // TODO add your handling code here:        
    }//GEN-LAST:event_txtBookIDBorrowCaretUpdate

    private void txtReaderIDBorrowCaretUpdate(javax.swing.event.CaretEvent evt) {//GEN-FIRST:event_txtReaderIDBorrowCaretUpdate
        // TODO add your handling code here:
    }//GEN-LAST:event_txtReaderIDBorrowCaretUpdate

    private void btnExitReturnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnExitReturnActionPerformed
        // TODO add your handling code here:
        cancel();
    }//GEN-LAST:event_btnExitReturnActionPerformed

    private void btnReturnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnReturnActionPerformed
        // TODO add your handling code here:
        if (rowSelectedReturn == -1) {
            JOptionPane.showMessageDialog(this, "Please choice data");
            return;
        }
        int IssueID = Integer.parseInt(txtIssueCodeReturn.getText());
        String ReaderID = txtReaderIDReturn.getText();
        String BookID = txtBookIDReturn.getText();
        try {
            out.writeObject("ReturnBook");
            out.writeObject(IssueID);
            out.writeObject(BookID);
            out.writeObject(ReaderID);
            String tb = (String) in.readObject();
            JOptionPane.showMessageDialog(this, tb);
            //Sau khi tra xong du thanh cong hay khong deu xoa du lieu;
            rowSelectedReturn = -1;
            removeTable(tbReturnBook, modelReturn);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }//GEN-LAST:event_btnReturnActionPerformed

    private void txtSearchBookReturnCaretUpdate(javax.swing.event.CaretEvent evt) {//GEN-FIRST:event_txtSearchBookReturnCaretUpdate
        // TODO add your handling code here:
    }//GEN-LAST:event_txtSearchBookReturnCaretUpdate

    private void btncheckFeeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btncheckFeeActionPerformed
        // TODO add your handling code here:
        try {
            out.writeObject("CheckFine");
            int IssueID = Integer.parseInt(txtIssueCodeReturn.getText());
            out.writeObject(IssueID);
            String CheckFine = (String) in.readObject();
            txtLateFees.setText(CheckFine);

        } catch (Exception e) {
            e.printStackTrace();
        }
    }//GEN-LAST:event_btncheckFeeActionPerformed

    private void txtSearchBookReturnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtSearchBookReturnActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txtSearchBookReturnActionPerformed

    private void btnResetReturnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnResetReturnActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_btnResetReturnActionPerformed

    private void txtSearchBookBorrowMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_txtSearchBookBorrowMouseClicked
        // TODO add your handling code here:
        if (txtSearchBookBorrow.getText().equals("")) {
            try {
                out.writeObject("ShowBookToIssue");
                arrBook = (ArrayList<Book>) in.readObject();                
                showDataBorrow();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }//GEN-LAST:event_txtSearchBookBorrowMouseClicked

    private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
     

    }//GEN-LAST:event_formWindowClosing

    private void txtReaderIDReturnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtReaderIDReturnActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txtReaderIDReturnActionPerformed

    private void showDataReturnReport(JTable tb, DefaultTableModel model) {
        removeTable(tb, model);
        for (IssueNote i : arrIss) {
            model.addRow(i.toVector());
        }
    }
    private void txtSearchBookReturnMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_txtSearchBookReturnMouseClicked
        // TODO add your handling code here:
        try {
            out.writeObject("ShowIssueNoteReturn");
            arrIss = (ArrayList<IssueNote>) in.readObject();
            if (arrIss == null) {
                JOptionPane.showMessageDialog(this, "Error load data, please try again");
            } else {
                showDataReturnReport(tbReturnBook, modelReturn);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }//GEN-LAST:event_txtSearchBookReturnMouseClicked

    private void txtSearchReportMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_txtSearchReportMouseClicked
        // TODO add your handling code here:
        try {
            out.writeObject("ShowIssueNoteReport");
            arrIss = (ArrayList<IssueNote>) in.readObject();
            if (arrIss == null) {
                JOptionPane.showMessageDialog(this, "Error load data, please try again");
            } else {
                showDataReturnReport(tbReport, modelReport);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }//GEN-LAST:event_txtSearchReportMouseClicked

    private void btnSearchBorrowActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSearchBorrowActionPerformed
        // TODO add your handling code here:
        int cbSelect = cbSearchBorrow.getSelectedIndex();
        try {
            if (cbSelect == 0) {
                JOptionPane.showMessageDialog(this, "Please choice type search");
            }
            if (cbSelect == 1) {
                out.writeObject("searchBookID");
                out.writeObject(txtSearchBookBorrow.getText());
                out.writeObject(1);
                Book b = new Book();
                b = (Book) in.readObject();
                if (b == null) {
                    JOptionPane.showMessageDialog(this, "This book was borrowed");
                }
                arrBook.removeAll(arrBook);
                arrBook.add(b);
            } else if (cbSelect == 2) {
                out.writeObject("searchTitleOrCategory");
                out.writeObject(txtSearchBookBorrow.getText() + "#2#1");
                arrBook = (ArrayList<Book>) in.readObject();
            }
            showDataBorrow();
        } catch (Exception e) {
        }
    }//GEN-LAST:event_btnSearchBorrowActionPerformed

    private void btnSearchReturnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSearchReturnActionPerformed
        // TODO add your handling code here:
        int cbSelect = cbSearchReturn.getSelectedIndex();
        if (cbSelect == 0) {
            JOptionPane.showMessageDialog(this, "Please choice type search");
            return;
        } else {
            try {
                if (cbSelect == 1) {
                    out.writeObject("SearchIssue");
                    out.writeObject(txtSearchBookReturn.getText());
                    out.writeObject("BookID");
                    out.writeObject(0);//Khong hien nhung phieu da tra roi                    
                } else if (cbSelect == 2) {
                    out.writeObject("SearchTitle");
                    out.writeObject(txtSearchBookReturn.getText());
                    out.writeObject(0);
                } else if (cbSelect == 3) {
                    out.writeObject("SearchIssue");
                    out.writeObject(txtSearchBookReturn.getText());
                    out.writeObject("ReaderID");
                    out.writeObject(0);//Khong hien nhung phieu da tra roi
                } else if (cbSelect == 4) {
                    out.writeObject("SearchFullName");
                    out.writeObject(txtSearchBookReturn.getText());
                    out.writeObject(0);
                }
                arrIss = (ArrayList<IssueNote>) in.readObject();
                showDataReturnReport(tbReturnBook, modelReturn);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }//GEN-LAST:event_btnSearchReturnActionPerformed

    private void btnSearchReportActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSearchReportActionPerformed
        // TODO add your handling code here:
        int cbSelect = cbSearchReport.getSelectedIndex();
        if (cbSelect == 0) {
            JOptionPane.showMessageDialog(this, "Please choice type search");
            return;
        } else {
            try {
                if (cbSelect == 1) {
                    out.writeObject("SearchIssue");
                    out.writeObject(txtSearchReport.getText());
                    out.writeObject("BookID");
                    out.writeObject(1);//Khong hien nhung phieu da tra roi                    
                } else if (cbSelect == 2) {
                    out.writeObject("SearchTitle");
                    out.writeObject(txtSearchReport.getText());
                    out.writeObject(1);
                } else if (cbSelect == 3) {
                    out.writeObject("SearchIssue");
                    out.writeObject(txtSearchReport.getText());
                    out.writeObject("ReaderID");
                    out.writeObject(1);//Khong hien nhung phieu da tra roi
                } else if (cbSelect == 4) {
                    out.writeObject("SearchFullName");
                    out.writeObject(txtSearchReport.getText());
                    out.writeObject(1);
                }
                arrIss = (ArrayList<IssueNote>) in.readObject();
                showDataReturnReport(tbReport, modelReport);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }//GEN-LAST:event_btnSearchReportActionPerformed
    
    /**
     * @param args the command line arguments
     */
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel VND;
    private javax.swing.JButton btnBorrow;
    private javax.swing.JButton btnExit;
    private javax.swing.JButton btnExitReturn;
    private javax.swing.JButton btnResetReturn;
    private javax.swing.JButton btnReturn;
    private javax.swing.JButton btnSearchBorrow;
    private javax.swing.JButton btnSearchReport;
    private javax.swing.JButton btnSearchReturn;
    private javax.swing.JButton btncheckFee;
    private javax.swing.JButton btnreset;
    private javax.swing.JComboBox cbSearchBorrow;
    private javax.swing.JComboBox cbSearchReport;
    private javax.swing.JComboBox cbSearchReturn;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JLabel lblAuthorBorrow;
    private javax.swing.JLabel lblBanner;
    private javax.swing.JLabel lblBookIDBorrow;
    private javax.swing.JLabel lblBookIDReturn;
    private javax.swing.JLabel lblCategoryBorrow;
    private javax.swing.JLabel lblDuaDateReturn;
    private javax.swing.JLabel lblDueDateBorrow;
    private javax.swing.JLabel lblIssueCodeReturn;
    private javax.swing.JLabel lblIssueDateBorrow;
    private javax.swing.JLabel lblIssueDateReturn;
    private javax.swing.JLabel lblLateFeeReturn;
    private javax.swing.JLabel lblPicture;
    private javax.swing.JLabel lblReaderID;
    private javax.swing.JLabel lblReaderIDReturn;
    private javax.swing.JLabel lblReturnDate;
    private javax.swing.JLabel lblSumaryBorrow;
    private javax.swing.JLabel lblTitleBorrow;
    private javax.swing.JPanel pnBorrowbook;
    private javax.swing.JPanel pnButton;
    private javax.swing.JPanel pnMain;
    private javax.swing.JPanel pnReportIssueNote;
    private javax.swing.JPanel pnReturnBook;
    private javax.swing.JTabbedPane tabPaneIssue;
    private javax.swing.JTable tbBorrow;
    private javax.swing.JTable tbReport;
    private javax.swing.JTable tbReturnBook;
    private javax.swing.JTextField txtAuthorBorrow;
    private javax.swing.JTextField txtBookIDBorrow;
    private javax.swing.JTextField txtBookIDReturn;
    private javax.swing.JTextField txtDueDateBorrow;
    private javax.swing.JTextField txtDueDateReturn;
    private javax.swing.JTextField txtIssueCodeReturn;
    private javax.swing.JTextField txtIssueDateBorrow;
    private javax.swing.JTextField txtIssueDateReturn;
    private javax.swing.JTextField txtLateFees;
    private javax.swing.JTextField txtPublisherBorrow;
    private javax.swing.JTextField txtReaderIDBorrow;
    private javax.swing.JTextField txtReaderIDReturn;
    private javax.swing.JTextField txtReturnDate;
    private javax.swing.JTextField txtSearchBookBorrow;
    private javax.swing.JTextField txtSearchBookReturn;
    private javax.swing.JTextField txtSearchReport;
    private javax.swing.JTextArea txtSumary;
    private javax.swing.JTextField txtTitleBorrow;
    // End of variables declaration//GEN-END:variables
}
